package com.xxx.modules.controller;;
import com.xxx.modules.service.CategoryService;
import com.xxx.modules.entity.Category;
import com.xxx.modules.entity.User;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
import com.github.pagehelper.PageInfo;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import com.xxx.modules.utils.Result;
import com.xxx.modules.utils.ResultUtil;
import com.xxx.modules.utils.*;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
/**
 * 类型
 *
 * @author Mark sunlightcs@gmail.com
 * @since 1.0.0 2024-03-30
 */
@RestController
@RequestMapping("/common/category")
@Api(tags="类型")
public class CategoryController {
    @Autowired
    private CategoryService categoryService;

    /**
    *  获取所有类型
    * @param pageNum
    * @param pageSize
    * @param category
    * @return
    */

    @GetMapping("/getCategoryList")
    @ApiOperation("获取所有类型")
    public Result getCategoryList(Category category, @RequestParam(value="pageNum",defaultValue = "1") Integer pageNum,
                                      @RequestParam(value="pageSize",defaultValue = "10") Integer pageSize){
        return categoryService.selectCategoryList(category,pageNum,pageSize);
    }


    @GetMapping("/getCategoryInfo")
    @ApiOperation("根据id获取单个类型")
    public Result getCategoryInfo(Integer id){
        return categoryService.selectCategoryInfo(id);
    }

    /**
    * 保存类型
    * @param category
    * @return
    */
    @PostMapping("/saveCategoryInfo")
    @ApiOperation("保存类型")
    public Result saveCategoryInfo(@RequestBody Category category){
        return categoryService.saveCategoryInfo(category);
    }


    /**
     * 更新类型
     * @param category
     * @return
     */

    @PutMapping("/updateCategoryInfo")
    @ApiOperation("更新类型")
    public Result updateCategoryInfo(@RequestBody Category category){
        return categoryService.updateCategoryInfo(category);
    }

    /**
     * 根据id删除类型
     * @param id
     * @return
     */
    @DeleteMapping("/delCategoryInfo")
    @ApiOperation("根据id删除类型")
    public Result delCategoryInfo(Integer id){
        return categoryService.delCategoryInfo(id);
    }

    /**
     * 根据id集合批量删除类型
     * @param idList
     * @return
     */
    @DeleteMapping("/delBatchCategoryInfo")
    @ApiOperation("根据id集合批量删除类型")
    public Result delBatchCategoryInfo(String idList){
        return categoryService.delBatchCategoryInfo(idList);
    }










}